<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>计算平方</title>
		<script>
			function cal(){
				var input_text = document.getElementById("num");
				var value = input_text.value;
				var span_result = document.getElementById("result");
				if(value == "" || isNaN(value)){
					span_result.innerHTML = '请输入数字';
				}else{
					span_result.innerHTML = value * value;
				}
			}
		</script>
	</head>
	<body>
		<P>
			<input type="text" id="num">
			<input type="button" value="平方" onclick="cal()">
		</P>
		<p>
			=<span id="result"></span>
		</p>
	</body>
</html>